
# 检查某个文件夹中是否存在指定的文件类型：
# if any(name.endswith(('.c', '.h')) for name in listdir(dirname)):

# >>> filename = 'spam.txt'
# >>> filename.endswith('.txt')
# True
# >>> filename.startswith('file:')
# False
# >>> url = 'http://www.python.org'
# >>> url.startswith('http:')
# True
# >>>


# >>> import os
# >>> filenames = os.listdir('.')
# >>> filenames
# [ 'Makefile', 'foo.c', 'bar.py', 'spam.c', 'spam.h' ]
# >>> [name for name in filenames if name.endswith(('.c', '.h')) ]
# ['foo.c', 'spam.c', 'spam.h'
# >>> any(name.endswith('.py') for name in filenames)
# True
# >>>

# from urllib.request import urlopen
#
#
# def read_data(name):
#     if name.startswith(('http:', 'https:', 'ftp:')):
#         return urlopen(name).read()
#     else:
#         with open(name) as f:
#             return f.read()